<?php

/**
 * MLEPP - ManiaLive Extending Plugin Pack
 * 
 * -- MLEPP Plugin --
 * @name Server Info
 * @date 21-02-2011
 * @version r842
 * @website mlepp.trackmania.nl
 * @package MLEPP
 * 
 * @author Guy "Knutselmaaster" Van Der Zel <knutselmaaster@gmail.com>
 * @copyright 2011
 * 
 * ---------------------------------------------------------------------
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * ---------------------------------------------------------------------
 * You are allowed to change things or use this in other projects, as
 * long as you leave the information at the top (name, date, version,
 * website, package, author, copyright) and publish the code under
 * the GNU General Public License version 3.
 * ---------------------------------------------------------------------
 */
 
namespace ManiaLivePlugins\MLEPP\ServerInfo;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Windows\InfoWindow;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls\Button;

use ManiaLive\DedicatedApi\Connection;
use ManiaLive\Features\Admin\AdminGroup;
use ManiaLive\Features\ChatCommand\Command;
use ManiaLive\Gui\Windowing\WindowHandler;
use ManiaLive\Gui\Windowing\Windows\Info;

use ManiaLive\Gui\Windowing\Listener;

use ManiaLive\Utilities\Console;
use ManiaLive\Gui\Handler;
use ManiaLive\Data\Storage;
use ManiaLive\Gui\Windowing\Window;
use ManiaLive\Event\Dispatcher;

use ManiaLivePlugins\MLEPP\Core\Core;

//use ManiaLivePlugins\MLEPP\ServerInfo\Adapter\oliverde8HudMenu;

class ServerInfo extends \ManiaLive\PluginHandler\Plugin {
    
    static $commandArray = array();
    public $login;
    
    public static $AdminName = "Unknown";
	public static $AdminContact = "";
   	public static $ServerSite = "";
   	
    public static $TeamName = "";
    public static $TeamSite = ""; 
    public static $TeamJoin = "";  
	
	public static $ServerLogins = array();
   	public static $ServerNames = array();
   
    /**
     * onInit()
     * Function called on initialisation of ManiaLive.
     * 
     * @return void
     */
    
    function onInit() {
        // this needs to be set in the init section
        $this->setVersion(842);
        $this->setPublicMethod('getVersion');

        //Oliverde8 Menu
        if($this->isPluginLoaded('oliverde8\HudMenu')){
            //Dispatcher::register(\ManiaLivePlugins\oliverde8\HudMenu\onOliverde8HudMenuReady::getClass(), $this);
        }

        //ML Repository
        if(Core::RepositoryId != null){
            $this->setRepositoryId(Core::RepositoryId);
            $this->setRepositoryVersion(Core::RepositoryVersion);
        }
    }

    /**
     * onLoad()
     * Function called on loading of ManiaLive.
     * 
     * @return void
     */

    function onLoad() {
        $this->enableDedicatedEvents();
        Console::println('['.date('H:i:s').'] [MLEPP] Plugin: ServerInfo r'.$this->getVersion().' by Knutselmaaster.');
        $help = "Shows serverinfo.";
        $cmd = $this->registerChatCommand("serverinfo", "sInfo", 0, true);
        $cmd->help = $help;
    }

    /**
     * sInfo()
     * Function providing the /sinfo command.
     * 
     * @param mixed $login
     * @return void
     */
     
    function sInfo($login) {
        $window = InfoWindow::Create($login); 
        $window->login=$login;
        $window->setTitle("Server Information");
       	$window->setSize(80,60);
        $window->centerOnScreen();
        $window->show();
		Console::println('['.date('H:i:s').'] [MLEPP] [ServerInfo] ['.$login.'] Player used /sinfo command.');
    }
}
?>